<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title><?=$this->session->config->title?></title>
    <link rel=stylesheet href="<?=base_url('public/mobile/jquery.mobile-1.4.5.min.css')?>">
    <script type="text/javascript" src="http://libs.baidu.com/jquery/1.8.3/jquery.min.js"></script>
    <script src="<?=base_url('public/mobile/jquery.mobile-1.4.5.min.js')?>"></script>
    <script src="<?=base_url('public/mobile/layer.m/layer.m.js')?>"></script>
    <script type="text/javascript" src="<?=base_url('public/lib/jqusey.form.js')?>"></script>
</head>
<body>
    <div data-role="page">
        <div data-role="header">
            <h1>用户注册</h1>
        </div>
        <div data-role="main" class="ui-content">
            <form method="post" action="<?=site_url('welcome/registered')?>" id="callAjaxForm">
                <label for="fname">登录帐号:</label>
                <input type="text" name="user_name" data-clear-btn="true">
                <label for="fname">登录密码:</label>
                <input type="password" name="pass" data-clear-btn="true">

                <label for="fname">确认密码:</label>
                <input type="password" name="password_1" data-clear-btn="true">
                <label for="fname">真实姓名:</label>
                <input type="text" name="name" data-clear-btn="true">
                <label for="fname">联系电话:</label>
                <input type="text" name="phone" data-clear-btn="true">
                <label for="fname">联系邮箱:</label>
                <input type="text" name="email" data-clear-btn="true">

                <label for="fname">QQ:</label>
                <input type="text" name="qq" data-clear-btn="true">
                <input type="hidden" name="address" data-clear-btn="true">
                <input type="hidden" name="company" data-clear-btn="true">
                <input type="hidden" name="weixin" data-clear-btn="true">

                <input type="hidden" name="pid" value="<?=$pid?>">
                <input type="submit" value="注册" id="submit">
                <input type="reset" value="重置">
            </form>
        </div>
    </div>
</body>
</html>

<script type="text/javascript">
    function onSuccess(data, status)
    {
        if(data == 1){
            layer.open({
                content: '注册成功，是否现在登录？',
                style:'width:600px',
                btn: ['确认', '取消'],
                shadeClose: false,
                yes: function(){
                    location.href="<?=site_url('welcome/index')?>";
                },
                no: function(){
                    layer.open({content: '取消', time: 1});
                }
            });

        }else{
            layer.open({
                content: data,
                style:'width:100%',
                btn: ['确定']
            });
        }
    }

    function onError(data, status)
    {
        alert(data);
    }

    $(document).ready(function() {
        $("#submit").click(function(){

            var formData = $("#callAjaxForm").serialize();

            $.ajax({
                type: "POST",
                url: "<?=site_url('welcome/registered')?>",
                cache: false,
                data: formData,
                success: onSuccess,
                error: onError
            });

            return false;
        });
    });
</script>